package com.example.dao;

import com.example.entity.User;
import java.util.HashMap;
import java.util.Map;

public class UserDao {
    // 模拟数据库
    private static final Map<String, User> users = new HashMap<>();

    static {
        // 初始化测试用户
        users.put("user1", new User("user1", "password1", "计科2001", "北京市海淀区中关村", "13800138000", "江苏省南京市"));
        users.put("user2", new User("user2", "password2", "软工2002", "上海市浦东新区张江", "13900139000", "浙江省杭州市"));
    }

    public User findByUsername(String username) {
        return users.get(username);
    }

    public boolean validateUser(String username, String password) {
        User user = findByUsername(username);
        return user != null && user.getPassword().equals(password);
    }
}